//
//  ZSchedulingTypeModel.m
//  Medicare
//
//  Created by LYY on 2017/8/9.
//  Copyright © 2017年 medicare. All rights reserved.
//

#import "ZSchedulingTypeModel.h"
#import "Common.h"
#import <objc/runtime.h>
@implementation ZSchedulingTypeModel

- (void)encodeWithCoder:(NSCoder *)encoder {
    unsigned int count = 0;
    Ivar *ivars = class_copyIvarList([ZSchedulingTypeModel class], &count);
    for (int i = 0; i<count; i++) {
        // 取出i位置对应的成员变量
        Ivar ivar = ivars[i];
        // 查看成员变量
        const char *name = ivar_getName(ivar);
        // 归档
        NSString *key = [NSString stringWithUTF8String:name];
        id value = [self valueForKey:key];
        [encoder encodeObject:value forKey:key];
    }
    free(ivars);
}

- (id)initWithCoder:(NSCoder *)decoder {
    if (self = [super init]) {
        unsigned int count = 0;
        Ivar *ivars = class_copyIvarList([ZSchedulingTypeModel class], &count);
        for (int i = 0; i<count; i++) {
            // 取出i位置对应的成员变量
            Ivar ivar = ivars[i];
            // 查看成员变量
            const char *name = ivar_getName(ivar);
            // 归档
            NSString *key = [NSString stringWithUTF8String:name];
            id value = [decoder decodeObjectForKey:key];
            // 设置到成员变量身上
            [self setValue:value forKey:key];
            
        }
        free(ivars);
    }
    return self;
}

- (BOOL)isEqual:(id)object {
    if (self == object) {
        return YES;
    }
    if (![object isKindOfClass:[ZSchedulingTypeModel class]]) {
        return NO;
    }
    ZSchedulingTypeModel *tekubaEntity = (ZSchedulingTypeModel *)object;
    
    if ([Common isBlankString:tekubaEntity.classInfoId] || [Common isBlankString:self.classInfoId]) {
        return NO;
    }

    if ([tekubaEntity.classInfoId isEqualToString: self.classInfoId]) {
        return YES;
    } else {
        return NO;
    }
}

@end
